package com.ph.seata.account.controller;


import com.ph.seata.account.dto.AccountDTO;
import com.ph.seata.account.service.AccountService;
import com.ph.web.common.response.WrapperResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author swallow
 * @since 2021-06-29
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/account")
public class AccountController {

    private final AccountService accountService;

    @PostMapping(value = "/dec_account")
    public WrapperResponse<Object> decAccount(@RequestBody AccountDTO accountDTO) {
        log.info("请求账户微服务：{}", accountDTO.toString());
        return accountService.decreaseAccount(accountDTO);
    }

    @GetMapping(value = "/test_global_lock")
    public void testGlobalLock() {
        log.info("testGlobalLock");
        accountService.testGlobalLock();
    }
}

